<?php
/**
 * Created by PhpStorm.
 * User: chenbin
 * Date: 15-5-13
 * Time: 下午5:07
 * gamil:bingoPureLife@gamil.com
 */

namespace Promoter\Common;
use Think\Model;
use Think\Page;
/*
 *
 * 数据库配置类
 * 此项目增删改查 全部基于配置配置模型采取array();
    常用操作 add  delete update select
    组合array edit add  type 0 1 2  1为自动模式 2为半自动模式  0为非自动模式
    field 可以通过sql 获得 为了节省所谓数据库请求  直接配置表字段数据
    所有搜索关系控制
    addEditFiled 负责添加和修改 字段和前台版面
    showFiled 负责要查询 展现的版面
    search 负责查询
    配置中where 条件务必将id配在第一项
 * */
class Config {
    /*
     *字典 扩展配置
     * 一个大array
     * 保证filed id 和 value
     * field  和 relafield 最好全部as key 统一处理
     * */

    private  static $dict = '
    {
        "addr":{
            "show":"地址信息",
            "input":"<div style=\"display: inline-block; *display: inline; *zoom:1;\" class=\"fill-cont\"><select id=\"s_province\" name=\"pro\"></select>&nbsp;&nbsp;<select id=\"s_city\" name=\"city\" ></select>&nbsp;&nbsp;<select id=\"s_county\" name=\"area\"></select><script class=\"resources library\" src=\"/Public/common/js/area.js\" type=\"text/javascript\"></script><script type=\"text/javascript\">_init_area();</script></div>"
        },
        "sex":{"0":"男","1":"女","2":"未知"},
        "isuse":{"0":"停用","1":"使用中"},
        "select_test_0001":{
            "tablename":"categroy","field":"`name` as value,`id` as id"
        },
        "checkbox_test_0001":{
            "tablename":"categroy","field":"`name` as value,`id` as id","relatable":"catetest","where":"`id`","relaField":"`cid` as id","operator":"="
        },
        "radio_test_0001":{
            "tablename":"categroy","field":"`name` as value,`id` as id"
        },
        "util":[
            {"show":"修改","class":"editBtns","url":"/index.php?s=/Home/Promoter/pmEdit/id/"},
            {"show":"删除","class":"delBtns confirm_bin","url":"/index.php?s=/Home/Promoter/pmDel/id/"}

        ],
        "yes_no":{"0":"否","1":"是"}
    }';
    /*
     *基础配置
     * */
    protected  static $dbUtilConfig =  '
	{ "promoter":{
                    "title":"推客",
                    "js":[
                            "/Public/common/js/bin.js"
                    ],
                    "addEditFiled":[
                        {"filed":"true_name","show":"推客名","type":"text","class":"fill-ipt"},
                        {"filed":"mobile","show":"电话号码","type":"text","class":"fill-ipt"},
                        {"filed":"statues","show":"使用状态","type":"radio","dict":"isuse","class":"","isrequrid":"required","default":"1"},
                        {"filed":"pro","type":"giveup"},
                        {"filed":"city","type":"giveup"},
                        {"filed":"area","type":"giveup"},
                        {"filed":"addr","show":"详细地址","type":"text","dict":"addr","class":"fill-ipt"},
                        {"filed":"un","show":"账户","type":"text","class":"fill-ipt"},
                        {"filed":"pw","show":"密码","type":"password","class":"fill-ipt"},
                        {"filed":"desc","show":"备注","type":"textarea","class":"fill-text"}
                    ],
                    "showFiled":[
                            {"field":"aid","show":"选择","width":"60px","dict":"check","dtype":"check"},
                            {"field":"true_name","show":"昵称","width":"100px"},
                            {"field":"pro","show":"省","width":"60px"},
                            {"field":"city","show":"市","width":"60px"},
                            {"field":"area","show":"区","width":"60px"},
                            {"field":"addr","show":"详细地址","width":"220px"},
                            {"field":"left_money","show":"可用余额","width":"100px"},
                            {"field":"able_out","show":"可提现余额","width":"100px"},
                            {"field":"able_invite","show":"邀请功能","dict":"yes_no","dtype":"sarray","width":"100px"},
                            {"field":"id","show":"操作","dict":"util","dtype":"util_","basePath":"/index.php?s=/Home/Promoter/pmEdit/id/","width":"220px"}
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_promoter","as":"test"},{"tableName":"yps_account","as":"account"}],
                         "where":[
                            {"forWhere":"account.`id`","show":"id查询","get":"id","operator":"=","linkedOperator":""},
                            {"forWhere":"test.`true_name`","show":"输入昵称查询","get":"true_name","operator":"like","linkedOperator":"AND","likeMatch":"all"}
                         ],
                         "rela":"account.`id` = test.`aid`",
                         "field": "test.*,account.`un`,account.`statues`",
                         "order":"test.`id` DESC",
                         "limit": "10"
                    }
                   },
        "getcash":{
                    "title":"申请提现",
                    "showFiled":[
                            {"field":"able_out","show":"可体现金额"}
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_promoter","as":"test"},{"tableName":"yps_account","as":"account"}],
                         "where":[
                            {"forWhere":"account.`id`","show":"id查询","get":"id","operator":"=","linkedOperator":""},
                            {"forWhere":"test.`true_name`","show":"输入昵称查询","get":"true_name","operator":"like","linkedOperator":"AND","likeMatch":"all"}
                         ],
                         "rela":"account.`id` = test.`aid`",
                          "field": "test.`able_out`,test.`mobile`,test.`true_name`,test.`id`,test.`alipay`,test.`alipayname`",
                         "order":"test.`id` DESC"
                    }
        },
         "userInfo":{
                   "title":"资料设置",
                   "addEditFiled":[
                          {"field":"true_name","show":"真实姓名","width":"100px"},
                          {"field":"mobile","show":"电话号码","width":"100px"},
                          {"field":"alipayname","show":"支付宝姓名","width":"100px"},
                          {"field":"paycount","show":"支付宝账号","width":"100px"}
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_promoter","as":"test"},{"tableName":"yps_account","as":"account"}],
                         "where":[
                            {"forWhere":"account.`id`","get":"id","operator":"=","linkedOperator":""}
                         ],
                         "rela":"account.`id` = test.`aid`",
                         "field": "test.`mobile`,test.`true_name`,test.`id`,test.`alipay`,test.`alipayname`",
                         "order":"test.`id` DESC"
                    }
         },
         "getCashLog":{
                   "title":"提现记录",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_getmoney_record","as":"test"},{"tableName":"yps_promoter","as":"p"}],
                         "where":[
                            {"forWhere":"test.`aid`","get":"id","operator":"=","linkedOperator":""},
                            {"forWhere":"test.`ctime`","get":"start","operator":">","linkedOperator":"AND"},
                            {"forWhere":"test.`ctime`","get":"end","operator":"<","linkedOperator":"AND"}
                         ],
                         "rela":"test.`aid` = p.`aid`",
                         "field": "test.*,p.`able_out`,p.`totle_money`",
                         "order":"test.`id` DESC",
                          "limit": "8"
                    }
         },
         "product":{
                   "title":"产品文案",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_product","as":"test"},{"tableName":"yps_provider","as":"p"}],
                         "where":[
                            {"forWhere":"test.`id`","get":"id","operator":"=","linkedOperator":""},
                            {"forWhere":"test.`utime`","get":"start","operator":">","linkedOperator":"AND"},
                            {"forWhere":"test.`utime`","get":"end","operator":"<","linkedOperator":"AND"},
                            {"forWhere":"test.`pro_name`","show":"输入商品名称查询","get":"pro_name","operator":"like","linkedOperator":"AND","likeMatch":"all"},
                            {"forWhere":"p.`id`","get":"pid","operator":"=","linkedOperator":"AND"}
                         ],
                         "rela":"test.`provide_id` = p.`id` AND test.`statues` = 1",
                         "field": "test.*,p.com_name",
                         "order":"test.`id` DESC",
                         "limit": "4"
                    }
         },
         "commistion":{
                   "title":"产品文案-佣金正序",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_product","as":"test"},{"tableName":"yps_provider","as":"p"}],
                         "rela":"test.`provide_id` = p.`id`",
                         "field": "test.*,p.com_name",
                         "order":"test.`tuike_commistion`",
                         "limit": "4"
                    }
         },
         "commistion_desc":{
                   "title":"产品文案-佣金倒序",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_product","as":"test"},{"tableName":"yps_provider","as":"p"}],
                         "rela":"test.`provide_id` = p.`id`",
                         "field": "test.*,p.com_name",
                         "order":"test.`tuike_commistion` DESC",
                         "limit": "4"
                    }
         },
          "promote":{
                   "title":"产品文案-推广正序",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_product","as":"test"},{"tableName":"yps_provider","as":"p"}],
                         "rela":"test.`provide_id` = p.`id`",
                         "field": "test.*,p.com_name",
                         "order":"test.`pro_order_num`",
                         "limit": "4"
                    }
         },
          "promote_desc":{
                   "title":"产品文案-推广倒序",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_product","as":"test"},{"tableName":"yps_provider","as":"p"}],
                         "rela":"test.`provide_id` = p.`id`",
                         "field": "test.*,p.com_name",
                         "order":"test.`pro_order_num` DESC",
                         "limit": "4"
                    }
         },
         "orders":{
                   "title":"我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""},
                            {"forWhere":"pro.`ctime`","get":"start","operator":">","linkedOperator":"AND"},
                            {"forWhere":"pro.`ctime`","get":"end","operator":"<","linkedOperator":"AND"},
                            {"forWhere":"pro.`pname`","show":"商品名称","get":"pname","operator":"like","linkedOperator":"AND","likeMatch":"all"},
                            {"forWhere":"pro.`id`","show":"extid","get":"extid","operator":"=","linkedOperator":"AND"}
                         ],
                         "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid`",
                         "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                         "order":"test.`id` desc",
                         "limit": "10"
                    }
         },
         "orders_desc":{
                   "title":"我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                        "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu`=1 AND test.`expressstatu` = 1 ",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
          "orders_ase":{
                   "title":"待签收-我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu`=1 AND  test.`expressstatu`=1",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
		 "orders_nopay":{
                   "title":"我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu` = 0",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
		 "orders_pay":{
                   "title":"我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu` = 1 ",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
		 "orders_stay":{
                   "title":"我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu` = 1 AND  test.`expressstatu` = 0",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
		 "orders_sign":{
                   "title":"已签收订单-我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`paystatu` = 1 AND  test.`expressstatu` = 2",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         },
		 "orders_unok":{
                   "title":"已签收订单-我推广获取的订单",
                     "js":[
                            "/Public/common/My97DatePicker/WdatePicker.js","/Public/common/js/bin.js","/Public/tuike/js/select.js"
                    ],
                    "serach":{
                         "tables":[{"tableName":"yps_order","as":"test"},{"tableName":"yps_vip","as":"p"},{"tableName":"yps_order_ext","as":"pro"}],
                          "where":[
                            {"forWhere":"pro.`promoterid`","get":"id","operator":"=","linkedOperator":""}
                         ],
                          "rela":"test.`uid` = p.`id` AND test.`id` = pro.`oid` AND  test.`statues` = 0",
                        "field": "pro.*,test.username,test.username,test.address,test.mobile,test.express,test.expressno,test.tradeno,test.expressstatu,test.paystatu",
                        "order":"test.`id` desc",
                        "limit": "10"
                    }
         }
    }
    ';
}